#include<stdio.h>
main() {
	int a[10] = {0}	, a1[6][6] = {0};;
	int fa[11] = {0};
	for(int i = 0; i < 10; i++)
		scanf("%d",&a[i]);
	for(int i = 1; i<11; i++)
		fa[i] = fa[i-1]+a[i-1];
	int i,j;
	scanf("%d%d",&i,&j);
	printf("%d",fa[j+1]-fa[i]);
	for(int i = 0; i < 5; i++)
		for(int j = 0; j < 5; j++) {
			scanf("%d",&a1[i][j]);
		}
	int fa1[6][6] = {0};
	for(int i = 1; i <= 5; i++)
		for(int j = 1; j <= 5; j++) {
			fa1[i][j] += a1[i-1][j-1]+fa1[i-1][j]+fa1[i][j-1]-fa1[i-1][j-1];
		}
	for(int i = 0; i < 5; i++) {
		for(int j = 0; j < 5; j++)
			printf("%d  ",a1[i][j]);
		printf("\n");
	}
	for(int i = 1; i <= 5; i++) {
		for(int j = 1; j <= 5; j++)
			printf("%d  ",fa1[i][j]);
		printf("\n");
	}
}

